/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.supinfo.youfood.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.validator.constraints.NotEmpty;

/**
 *
 * @author Michael
 */
@Entity
@Table(name="employe")
public class Employe implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id_employe;
    
    @NotEmpty
    private String nom;
    
    @NotEmpty
    private String prenom;
    
    @NotNull
    private int code_acces;
    
    @ManyToOne
    @JoinColumn(name="fk_type_employe")
    private TypeEmploye type_employe;
    
    @OneToMany(mappedBy="serveur",fetch= FetchType.EAGER)
    @Fetch(FetchMode.SUBSELECT)
    private List<Commande> commandesEnCours;
    
    @ManyToOne
    @JoinColumn(name="fk_id_restaurant")
    private Restaurant resto;
    
    @OneToMany(mappedBy="serveur",fetch= FetchType.EAGER)
    @Fetch(FetchMode.SUBSELECT)
    private List<TableResto> tables;

    public Employe() {
    }

    public Employe(String nom, String prenom, int code_acces) {
        this.nom = nom;
        this.prenom = prenom;
        this.code_acces = code_acces;
    }
    
    public Employe (int code_acces) {
        this.code_acces = code_acces;
    }

    public Long getId_employe() {
        return id_employe;
    }

    public void setId_employe(Long id_employe) {
        this.id_employe = id_employe;
    }

    public int getCode_acces() {
        return code_acces;
    }

    public void setCode_acces(int code_acces) {
        this.code_acces = code_acces;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public TypeEmploye getType_employe() {
        return type_employe;
    }

    public void setType_employe(TypeEmploye type_employe) {
        this.type_employe = type_employe;
    }

    public List<Commande> getCommandesEnCours() {
        return commandesEnCours;
    }

    public void setCommandesEnCours(List<Commande> commandesEnCours) {
        this.commandesEnCours = commandesEnCours;
    }

    public Restaurant getResto() {
        return resto;
    }

    public void setResto(Restaurant resto) {
        this.resto = resto;
    }

    public List<TableResto> getTables() {
        return tables;
    }

    public void setTables(List<TableResto> tables) {
        this.tables = tables;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Employe other = (Employe) obj;
        if (this.id_employe != other.id_employe && (this.id_employe == null || !this.id_employe.equals(other.id_employe))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        return hash;
    }
    
}